// 删除单个日志
export function deleteLog(id) {
  return requestWithErrorHandling({
    url: `/logs/${id}`,
    method: "DELETE",
    errorMessage: "删除日志失败",
  });
}

// 批量删除日志
export function batchDeleteLogs(ids) {
  return requestWithErrorHandling({
    url: `/logs/batch/${ids}`,
    method: "DELETE",
    errorMessage: "批量删除日志失败",
  });
}
import { requestWithErrorHandling } from "./request";

// 获取日志列表，支持传递查询参数（如分页、筛选等）
export function fetchLogs(params = {}) {
  return requestWithErrorHandling({
    url: "/logs/list",
    method: "get",
    params,
    errorMessage: "获取日志列表失败",
  }).then((res) => {
    if (res.code === 1 && res.data && Array.isArray(res.data.list)) {
      return {
        total: res.data.total,
        list: res.data.list.map((item) => ({
          ...item,
          // 可在此补充或格式化字段
          // createdAt: item.createdAt && new Date(item.createdAt).toLocaleString(),
        })),
      };
    }
    return { total: 0, list: [] };
  });
}
